import React from "react";
import {
    HashRouter as Router,
    Route,
    Link,
    Redirect,
    Switch
} from 'react-router-dom'

import asyncTemplate from './async.template';
import ReactDOM from "react-dom";

const HomePage = asyncTemplate(() => import('./Home/HomePage'));
const NoMatch = asyncTemplate(() => import('./Home/NoMatch'));
const ProductDetail = asyncTemplate(() => import('./Home/ProductDetail'));
const OrderIndex = asyncTemplate(() => import('./Order/Index'));
const UserIndex = asyncTemplate(() => import('./User/Index'));
const About = asyncTemplate(() => import('./User/About'));
const Setting = asyncTemplate(() => import('./User/Setting'));
const Coupon = asyncTemplate(() => import('./User/Coupon'));
const OrderDetail = asyncTemplate(() => import('./Order/OrderDetail'));
const TopicList = asyncTemplate(() => import('./Home/TopicList'));
const MajorList = asyncTemplate(() => import('./Home/MajorList'));
const ProductList = asyncTemplate(() => import('./Home/ProductList'));
const OrderPay = asyncTemplate(() => import('./Home/OrderPay'));
const CouponProductList = asyncTemplate(() => import('./Home/CouponProductList'));


const router = (
    <Router>
        <Switch>
            <Route path="/" exact component={HomePage}/>
            <Route path="/ProductDetail" component={ProductDetail}/>
            <Route path="/OrderIndex" component={OrderIndex}/>
            <Route path="/UserIndex" component={UserIndex}/>
            <Route path="/About" component={About}/>
            <Route path="/Setting" component={Setting}/>
            <Route path="/Coupon" component={Coupon}/>
            <Route path="/OrderDetail" component={OrderDetail}/>
            <Route path="/TopicList" component={TopicList}/>
            <Route path="/MajorList" component={MajorList}/>
            <Route path="/ProductList" component={ProductList}/>
            <Route path="/OrderPay" component={OrderPay}/>
            <Route path="/CouponProductList" component={CouponProductList}/>
            <Route component={NoMatch}/>
        </Switch>
    </Router>
)

export default router;
